package cn.cmeizu.spring6.validator.two;

import jakarta.validation.ConstraintViolation;
import jakarta.validation.Validator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * @author cmeizu
 * @date 2023/2/19 18:56
 * 原生的校验器实现
 */
@Service
public class MyValidation1 {

  @Autowired
  private Validator validator;

  public boolean validatorByUserOne(User user) {
    Set<ConstraintViolation<User>> validate = validator.validate(user);
    return validate.isEmpty();
  }
}
